package com.rykj.qxj.test.xtest;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.rykj.qxj.server.util.date.DateUtils;

public class MapSumFile {

	public static void main(String[] args) {
		
		//List<Map<String,Object>> listMap=new 
		
		SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyy-MM");   
		String date=sDateFormat.format(new Date());  
		System.out.println(date);
		
		
		
		SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM");
		List<Map<String, Object>> initMapList=new ArrayList<Map<String,Object>>();
		for(int i=1;i<=12;i++) {
			Map<String,Object> map=new HashMap<>();
			Date addHowMonth = DateUtils.addHowMonth(new Date(), -i);
			map.put("month", sdf3.format(addHowMonth));
			map.put("value", "0");
			initMapList.add(map);
		}
		
		 Collections.sort(initMapList, new Comparator<Map<String,Object>>(){
				@Override
				public int compare(Map<String, Object> o1, Map<String, Object> o2) {
					int temp=Integer.valueOf(o1.get("month").toString().replaceAll("-", ""))>Integer.valueOf(o2.get("month").toString().replaceAll("-", ""))?-1:0;
					return temp;
				}
			
		});
		System.out.println(initMapList);

	}

}
